﻿#include "InstructionThermostatTemperatureRate.h"

__SCRIPTINSTRUCTION_REGISTER(InstructionThermostatTemperatureRate,ScriptInstruction::Instruction_Thermostat_TemperatureRate,&InstructionThermostatTemperatureRate::fromByteArray1);

InstructionThermostatTemperatureRate::InstructionThermostatTemperatureRate()
{
  instructionFlag = Instruction_Thermostat_TemperatureRate;
}

InstructionThermostatTemperatureRate::InstructionThermostatTemperatureRate(InstructionThermostatTemperatureRate const& instructionThermostatTemperatureRate)
{
  *this=instructionThermostatTemperatureRate;
}

InstructionThermostatTemperatureRate& InstructionThermostatTemperatureRate::operator=(InstructionThermostatTemperatureRate const & instructionThermostatTemperatureRate)
{
  *(ScriptInstruction*)this=instructionThermostatTemperatureRate;
  temperatureRate=instructionThermostatTemperatureRate.temperatureRate;
  return *this;
}

InstructionThermostatTemperatureRate::~InstructionThermostatTemperatureRate()
{}

QString InstructionThermostatTemperatureRate::toString()
{
  return QStringLiteral("设置温箱变温速率，速率：%1℃/m").arg(temperatureRate,0,'f',4);
}

QByteArray InstructionThermostatTemperatureRate::toByteArray()
{
  return QByteArray().append((char*)&temperatureRate,sizeof (temperatureRate));
}

InstructionThermostatTemperatureRate* InstructionThermostatTemperatureRate::clone()
{
  return new InstructionThermostatTemperatureRate(*this);
}

ScriptInstruction* InstructionThermostatTemperatureRate::fromByteArray1(char * const src,int size,int * offset)
{
  if((size-*offset)<byteArraySize)
    {
      return Q_NULLPTR;
    }
  InstructionThermostatTemperatureRate* instructionThermostatTemperatureRate=new InstructionThermostatTemperatureRate();
  instructionThermostatTemperatureRate->temperatureRate=*(float*)(src+*offset);
  *offset+=sizeof (temperatureRate);
  return instructionThermostatTemperatureRate;
}

float InstructionThermostatTemperatureRate::getTemperatureRate()
{
  return temperatureRate;
}

InstructionThermostatTemperatureRate* InstructionThermostatTemperatureRate::setTemperatureRate(float temperatureRate)
{
  this->temperatureRate=temperatureRate;
  return this;
}
